package razor.blade;

import javafx.beans.binding.*;
import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.scene.shape.*;
import javafx.beans.property.*;
import javafx.beans.value.*;
import tee.binding.*;

public class ScrapeHorizontal {
    private Numeric x;
    private Numeric y;
    private Numeric width;
    private Group root;
    //private Polygon flare;
    public Node node() {
        return root;
    }
    public ScrapeHorizontal x(double it) {
	x.value(it);
	return this;
    }
    public ScrapeHorizontal x(int it) {
	x.value(it);
	return this;
    }
    public Numeric x() {
	return x;
    }
    public ScrapeHorizontal x(It<Double> it) {
	x.bind(it);
	return this;
    }
    public ScrapeHorizontal y(double it) {
	y.value(it);
	return this;
    }
    public ScrapeHorizontal y(int it) {
	y.value(it);
	return this;
    }
    public Numeric y() {
	return y;
    }
    public ScrapeHorizontal y(It<Double> it) {
	y.bind(it);
	return this;
    }
    
    public ScrapeHorizontal width(double it) {
	width.value(it);
	return this;
    }
    public ScrapeHorizontal width(int it) {
	width.value(it);
	return this;
    }
    public Numeric width() {
	return width;
    }
    public ScrapeHorizontal width(It<Double> it) {
	width.bind(it);
	return this;
    }
    
    public ScrapeHorizontal() {
        x = new Numeric().value(0);
        y = new Numeric().value(0);
        width = new Numeric().value(100);
        root = new Group();
        
        Rectangle r1 = new Rectangle();
        r1.xProperty().bind(new Tee<Double>(x));
        r1.yProperty().bind(new Tee<Double>(y));
        r1.widthProperty().bind(new Tee<Double>(width));
        r1.heightProperty().set(1);
        Stop[] stops1 = new Stop[]{new Stop(0, Color.web("#00000000")), new Stop(0.5, Color.web("#000000aa")), new Stop(1, Color.web("#00000000"))};
        LinearGradient fill1 = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops1);
        r1.setFill(fill1);
        root.getChildren().add(r1);
        
        Rectangle r2 = new Rectangle();
        r2.translateYProperty().set(1);
        r2.xProperty().bind(r1.xProperty());
        r2.yProperty().bind(r1.yProperty());
        r2.widthProperty().bind(r1.widthProperty());
        r2.heightProperty().set(1);
        Stop[] stops2 = new Stop[]{new Stop(0, Color.web("#ffffff00")), new Stop(0.5, Color.web("#ffffff66")), new Stop(1, Color.web("#ffffff00"))};
        LinearGradient fill2 = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops2);
        r2.setFill(fill2);
        root.getChildren().add(r2);
    }
}
